"""
    create by IAmFiveHigh on 2023/8/24
"""
import math

import matplotlib.pyplot as plt

from LA.Matrix import Matrix

if __name__ == '__main__':
    points = [[0, 0], [0, 5], [3, 5], [3, 4], [1, 4],
              [1, 3], [2, 3], [2, 2], [1, 2], [1, 0],
              [0, 0]]

    x = [point[0] for point in points]
    y = [point[1] for point in points]

    plt.figure(figsize=(5, 5))
    plt.xlim(-10, 10)
    plt.ylim(-10, 10)
    plt.plot(x, y)

    P = Matrix(points)
    p1 = P.T()

    # 横向缩放矩阵
    # T = Matrix([[2, 0], [0, 1]])

    # 翻转矩阵
    # T = Matrix([[1, 0], [0, -1]])

    # 错切矩阵
    # T = Matrix([[1, 1], [0, 1]])

    # 旋转矩阵
    theta = math.pi / 6
    T = Matrix([[math.cos(theta), math.sin(theta)],
                [-math.sin(theta), math.cos(theta)]])

    p2 = T.dot(p1)

    plt.plot([p2.col_vector(i)[0] for i in range(p2.col_num())],
             [p2.col_vector(i)[1] for i in range(p2.col_num())])
    plt.show()



